package it.antonio.ilpizze.db.core;

import static it.antonio.ilpizze.db.core.Status.OPEN;
import it.antonio.ilpizze.db.Globals;
import it.antonio.ilpizze.db.io.IOConstants;

public class GlobalConfiguration implements Globals, IOConstants {
	
	private TransactionManager transactionManager;
	private StatusManager statusManager;
	private LockManager lockManager;
	
	public GlobalConfiguration(TransactionManager transactionManager, StatusManager statusManager, LockManager lockManager) {
		this.transactionManager = transactionManager;
		this.statusManager = statusManager;
		this.lockManager = lockManager;
	}

	@Override
	public Globals autoCommit(boolean ac) {
		statusManager.checkStatus(OPEN);
		
		transactionManager.autoCommit(ac);
		
		return this;
	}
	
	@Override
	public Globals multiThreading(boolean multiThreading) {
		statusManager.checkStatus(OPEN);
		statusManager.multiThreading(multiThreading);
		transactionManager.multiThreading(multiThreading);
		
		lockManager.multiThreading(multiThreading);
		
		return this;
	}
	
}
